
var loc_stor = {};//本地缓存
function Ajax(ec_type,btime3,line_type,dname,lid){
    ec_type = ec_type || 'line';
    btime3 = btime3 || '2015年07月';
    line_type = line_type || 'tnum';
    dname = dname || '';
    lid = lid || '';
    var year = btime3.substr(0,4);
    var month = btime3.substr(5,2);
    var key = ec_type+year+month+line_type+dname+lid;
    require.config({
        paths: {
            echarts: 'http://www.12301.cc/js/echarts-2.2.1/src',
            theme  : 'http://www.12301.cc/js/echarts-2.2.1/src/theme',
            zrender: 'http:///www.12301.cc/js/echarts-2.2.1/zrender'
        }
    });
    require(
        [
            'echarts',
            'theme/macarons',
            'echarts/chart/line',
            'echarts/chart/pie',
            'echarts/chart/map'
        ],
        function (ect,theme) {
            var dom = $('#main')[0];
            var myChart = ect.init(dom,theme);
            myChart.showLoading({
                text: "正在拼命加载数据(｡・`ω´･)",
                effect:'dynamicLine'
            });
            if(loc_stor[key]){
                myChart.hideLoading();
                myChart.setOption(loc_stor[key]);
            }
            else{
                PFT_GLOBAL.G.Ajax({
                        url : "t.php",
                        data : {action:ec_type,btime3:btime3,line_type:line_type,dname:dname,lid:lid},
                        dataType : "json",
                        type :'POST',
                        loading:function(){},
                        timeout : function(){console && console.log("获取数据超时")},
                        serverError : function(){console &&
                        console.log("接口出错:map_3/t.php?"+ec_type)}
                    },function(res){
                        myChart.hideLoading();
                        loc_stor[key] = res;
                        myChart.setOption(res);
                })
            }
        }
    )
}




